unit EMailTemplatefrm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Basefrm, StdCtrls, pngimage, ExtCtrls, Buttons, DBGridEhGrouping,
  DBCtrls, GridsEh, DBGridEh, DB, ADODB, Mask;

type
  TEMailTemplateDlg = class(TBaseDlg)
    pnl1: TPanel;
    btnOK: TBitBtn;
    btnCancle: TBitBtn;
    adsEMailTemplate: TADODataSet;
    dsEMailTemplate: TDataSource;
    pnl2: TPanel;
    dbmmotemplate: TDBMemo;
    dbedtTitle: TDBEdit;
    pnl3: TPanel;
    dbgrdh1: TDBGridEh;
    lstVar: TListBox;
    procedure adsEMailTemplateNewRecord(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

   procedure ShowEMailTemplateDlg();

implementation

uses ClientSystemUnit, DM;

{$R *.dfm}

  procedure ShowEMailTemplateDlg();
  begin
    with TEMailTemplateDlg.Create(nil) do
    try
      DataM.conDB.BeginTrans;
      adsEMailTemplate.Open;
      if ShowModal = mrOk then
      begin
        if adsEMailTemplate.State in [dsEdit, dsInsert] then
          adsEMailTemplate.Post;

        DataM.conDB.CommitTrans;
        DataM.adsMailTemplate.Close;
        DataM.adsMailTemplate.Open;
      end
      else
        DataM.conDB.RollbackTrans;

    finally
      Free;
    end;
  end;

procedure TEMailTemplateDlg.adsEMailTemplateNewRecord(DataSet: TDataSet);
begin
  DataSet.FieldByName('MATE_GUID').AsString := NewGuid;
  DataSet.FieldByName('MATE_HASTEMPLATE').AsBoolean := False;
  DataSet.FieldByName('MATE_STYLE').AsInteger := 0;

end;

end.
